import React, { useState, useEffect } from 'react'
/**
 * 参数是啥？需不需要参数？
 * 返回值是啥，需不需要返回值？
 */
export const usePosition = () => {
  const [position, setPosition] = useState({ x: 0, y: 0 })

  useEffect(() => {
    const move = e => {
      setPosition({
        x: e.clientX,
        y: e.clientY
      })
    }

    window.addEventListener('mousemove', move)

    return () => {
      window.removeEventListener('mousemove', move)
    }
  }, [])

  return { position }
}
